#include<bits/stdc++.h>
using namespace std;
int T;
int x[101000],v[101000],a[101000],c[101000];
int ch[4000][3010];
int flag[101000],chao[10100];
int n,m,l,vm;
int dp(int h,int kk){
    if(kk==0){
        if(h==m){
            return 0;
        }
        else{
            int ans1=0,ans2=0;
            ans1=dp(h+1,0);
            ans2=dp(h+1,1);
            return max(ans1,ans2);
        }
    }
    else{
        int ok=1;
        for(int i=1;i<=flag[h];i++){
            chao[ch[h][i]]--;
            if(chao[ch[h][i]]<=0){
                ok=0;
            }
        }
        for(int i=1;i<=flag[h];i++){
            chao[ch[h][i]]++;
        }
        if(h==m){
            if(ok==1){
                return 1;
            }
            else{
                return 0;
            }
        }
        else{
            if(ok==1){
                for(int i=1;i<=flag[h];i++){
                     chao[ch[h][i]]--;
                }
                int ans1=0,ans2=0;
                ans1=dp(h+1,0)+1;
                ans2=dp(h+1,1)+1;
                return max(ans1,ans2);
            }
            else{
                return 0;
            }
        }
    }
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int t=1;t<=T;t++){
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(x,0,sizeof(x));
        memset(c,0,sizeof(c));
        int flagzhen=1;
        int flagfu=1;
        int flag0=1;
        cin>>n>>m>>l>>vm;
        for(int i=1;i<=n;i++){
            cin>>x[i]>>v[i]>>a[i];
            if(a[i]>0){
                flag0=0;
                flagfu=0;
            }
            if(a[i]<0){
                flagzhen=0;
                flag0=0;
            }
        }
        for(int i=1;i<=m;i++){
            cin>>c[i];
        }
        sort(c+1,c+m+1);
        if(flag0==1){
            int ans=0;
            for(int i=1;i<=n;i++){
                if(v[i]>vm&&x[i]<=c[m]){
                    ans++;
                }
            }
            cout<<ans<<" ";
            if(ans==0){
                cout<<m<<endl;
            }
            else{
                cout<<m-1<<endl;
            }
            continue;
        }
        if(flagzhen==1){
            int ans=0;
            for(int i=1;i<=n;i++){
                int vvm=vm*vm;
                if(x[i]<c[m]){
                    int vz=v[i]*v[i]+2*a[i]*(c[m]-x[i]);
                    if(vz>vvm){
                        ans++;
                    }
                }
                else if(x[i]==c[m]){
                    if(v[i]>vm){
                        ans++;
                    }
                }
            }
            cout<<ans<<" ";
            if(ans==0){
                cout<<m<<endl;
            }
            else{
                cout<<m-1<<endl;
            }
            continue;
        }
        if(flag0==0&&flagzhen==0){
            int ans=0;
            memset(ch,0,sizeof(ch));
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    if(x[i]<=c[j]){
                        int vvm=vm*vm;
                        int vz=v[i]*v[i]+2*a[i]*(c[j]-x[i]);
                        if(vz>vvm){
                            ans++;
                            break;
                        }
                    }
                }
            }
            cout<<ans<<" ";
            for(int i=1;i<=4000;i++){
                flag[i]=1;
            }
            memset(chao,0,sizeof(chao));
            memset(ch,0,sizeof(ch));
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    if(x[i]<=c[j]){
                        int vvm=vm*vm;
                        int vz=v[i]*v[i]+2*a[i]*(c[j]-x[i]);
                        if(vz>vvm){
                            chao[i]++;
                            ch[j][flag[j]]=i;
                            flag[j]++;
                        }
                    }
                }
            }
            if(ans==0){
                cout<<m<<endl;
            }
            else{
                int jian=0;
                jian=max(dp(1,0),dp(1,1));
                cout<<m-jian<<endl;
            }
        }

    }
    return 0;
}
